///////////////////////////////////////////////////////////
// 
//  MyWindow.h
//
//  Wiicussion
//  HCI 575 Class project
//  Spring 2007
// 
//  Authors:  Jeremy Bennett
//            Adam Faeth
//            Michael Oren
//
///////////////////////////////////////////////////////////

// Local Includes
#include "MyContext.h"
#include "Player.h"
#include "Game.h"
#include "MyStage.h"

// SDL Includes
#include <sdl.h>

// System Includes

class MyWindow
{
  public:
    // Constructor / Destructor
    MyWindow();
    ~MyWindow();
  
    // Init / Fini
    bool init();
    bool fini();

    // Execute
    bool execute( int argv, char* argc[] );

    bool setViewPort( int x, int y, int w, int h );

  protected:
    // Rendering
    bool _preFrame();
    bool _postFrame();
    bool _render();

    bool _renderBackground();
    bool _renderMenu();
    bool _renderWarning();
    
    // Input
    bool _handleEvents();
    bool _updateState();
    bool _updatePlaying( int player, int iMote );
  
    // Initialization 
    bool _initGL();
    bool _initJoystick();
    bool _initWiimote();

  protected:

    MyContext         _context;

    // SDL Surface
    SDL_Surface      *_pSurface;

    // SDL Joystick
    SDL_Joystick     *_pJoystick[8];
    int               _nJoystick;
    
    // Number of players
    int               _nPlayer;
    Player            _player[4];
    bool              _bPlaying[4][2];
    
    // Game
    Game           * _pGame;
    MyStage          _stage; 

    // Size
    int     _w;
    int     _h;

    // Exit variable
    bool    _bQuit;
};
